from time import sleep
import uiautomation
import pyautogui


class Menzhentuifang():
    his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
    his.SetFocus()
#定位
    huanzhexingming = his.EditControl(AutomationId='hzxm_txt', ClassName='TextBox')#患者姓名输入框
    yishengxingming = his.EditControl(AutomationId='PART_TextBox', ClassName='TextBox')#医生姓名输入框
    weishoufei = his.CheckBoxControl( ClassName='CheckBox',Name='未收费')#未收费复选按钮
    chaxun = his.ButtonControl(AutomationId='search_btn',ClassName='Button',Name='查询') #查询按钮
    tuifang = his.ButtonControl(AutomationId='tf_btn', ClassName='Button',Name='退方') #退方按钮
    quxiaotuifang = his.ButtonControl(ClassName='Button',Name='取消退方') #取消退方按钮
    shanchuchufang = his.ButtonControl(ClassName='Button',Name='删除处方') #删除处方按钮
    shanchuweishoufeichufang = his.ButtonControl(ClassName='Button',Name='删除未收费处方')#删除未收费处方按钮

    tishi = his.WindowControl(ClassName='Window',Name='提示')
    tishiqueding = tishi.ButtonControl(AutomationId='OkBtn', ClassName='Button',Name='确定')
    tishiquxiao = tishi.ButtonControl(AutomationId='CancelBtn', ClassName='Button',Name='取消')
    chufangliebiao = his.DataGridControl(AutomationId='cflb_ydg', ClassName='YDataGrid')
    chufang1 = chufangliebiao.DataItemControl(Name='Ksy.ChssClient.Access.Model.CFCXLIST', ClassName='DataGridRow',foundIndex=1)
    chufang2 = chufangliebiao.DataItemControl(Name='Ksy.ChssClient.Access.Model.CFCXLIST', ClassName='DataGridRow',foundIndex=2)
    chufang3 = chufangliebiao.DataItemControl(Name='Ksy.ChssClient.Access.Model.CFCXLIST', ClassName='DataGridRow',foundIndex=3)
    chufang4 = chufangliebiao.DataItemControl(Name='Ksy.ChssClient.Access.Model.CFCXLIST', ClassName='DataGridRow',foundIndex=4)
    chufang5 = chufangliebiao.DataItemControl(Name='Ksy.ChssClient.Access.Model.CFCXLIST', ClassName='DataGridRow',foundIndex=5)
    chufang6 = chufangliebiao.DataItemControl(Name='Ksy.ChssClient.Access.Model.CFCXLIST', ClassName='DataGridRow',foundIndex=6)

#方法
    #输入患者姓名
    def input_hzxm(self,hzxm):
        self.huanzhexingming.Click()
        pyautogui.hotkey('ctrl', 'a')
        pyautogui.press('back')
        self.huanzhexingming.SendKeys(hzxm)

    #输入医生姓名
    def input_ysxm(self,ysxm):
        self.yishengxingming.Click()
        self.yishengxingming.SendKeys(ysxm)
        pyautogui.press('enter')
        sleep(1)
    #点击未收费
    def click_weishoufei_btn(self):
        self.weishoufei.Click()
        sleep(1)
    #点击查询
    def click_chaxun_btn(self):
        self.chaxun.Click()
    #点击退方
    def click_tuifang_btn(self):
        self.tuifang.Click()
    #点击取消退方
    def click_quxiaotuifang_btn(self):
        self.quxiaotuifang.Click()
    #点击删除处方
    def click_shanchuchufang_btn(self):
        self.shanchuchufang.Click()

    #点击删除未收费处方
    def click_shanchuweishoufeichufang_btn(self):
        self.shanchuweishoufeichufang.Click()
    #提示弹窗确定
    def click_tishiqueding_btn(self):
        self.tishiqueding.Click()
        sleep(1)

    #提示弹窗取消
    def click_tishiquxiao_btn(self):
        self.tishiquxiao.Click()

    #点击第一条数据
    def click_chufang1(self):
        self.chufang1.DoubleClick()

    #点击第一条数据
    def click_chufang2(self):
        self.chufang2.DoubleClick()

    #点击第一条数据
    def click_chufang3(self):
        self.chufang3.DoubleClick()

    #点击第一条数据
    def click_chufang4(self):
        self.chufang4.DoubleClick()

    #点击第一条数据
    def click_chufang5(self):
        self.chufang5.DoubleClick()

    #点击第一条数据
    def click_chufang6(self):
        self.chufang6.DoubleClick()